1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package de.bea.domingo.monitor;
24
25 import org.apache.commons.logging.Log;
26 import org.apache.commons.logging.LogFactory;
27
28 import de.bea.domingo.DNotesMonitor;
29
30 /***
31 * Adapter from Apache Commons Logging to the domingo monitor interface.
32 *
33 * <p>Use an instance of this class as argument to
34 * DNotesFactory.getInstance(DNotesMonitor theMonitor).</p>
35 *
36 * <p>If Apache Commons Logging should be used for logging, the commons-logging.jar
37 * file must be available in the classpath. Apache Commons Logging can be downloaded at
38 * <a target="_blank" href="http://jakarta.apache.org/commons/logging/"></a>.</p>
39 *
40 * @since domingo 1.1
41 */
42 public final class LoggingMonitor implements DNotesMonitor {
43
44 /*** Reference to the log that will receive all log messages from Domingo. */
45 private Log logger;
46
47 /***
48 * Constructor.
49 *
50 * <p>Creates a monitor with a default log.</p>
51 */
52 public LoggingMonitor() {
53 this(LogFactory.getLog(LoggingMonitor.class));
54 }
55
56 /***
57 * Constructor.
58 *
59 * @param log a log instance
60 */
61 public LoggingMonitor(final Log log) {
62 logger = log;
63 }
64
65 /***
66 * Returns the current log.
67 *
68 * @return current log
69 */
70 public Log getLogger() {
71 return logger;
72 }
73
74 /***
75 * Sets a new log.
76 *
77 * @param log the new log
78 */
79 public void setLogger(final Log log) {
80 this.logger = log;
81 }
82
83 /***
84 * {@inheritDoc}
85 * @see de.bea.domingo.DNotesMonitor#debug(java.lang.String, java.lang.Throwable)
86 */
87 public void debug(final String message, final Throwable throwable) {
88 logger.debug(message, throwable);
89 }
90
91 /***
92 * {@inheritDoc}
93 * @see de.bea.domingo.DNotesMonitor#debug(java.lang.String)
94 */
95 public void debug(final String message) {
96 logger.debug(message);
97 }
98
99 /***
100 * {@inheritDoc}
101 * @see de.bea.domingo.DNotesMonitor#info(java.lang.String, java.lang.Throwable)
102 */
103 public void info(final String message, final Throwable throwable) {
104 logger.info(message, throwable);
105 }
106
107 /***
108 * {@inheritDoc}
109 * @see de.bea.domingo.DNotesMonitor#info(java.lang.String)
110 */
111 public void info(final String message) {
112 logger.info(message);
113 }
114
115 /***
116 * {@inheritDoc}
117 * @see de.bea.domingo.DNotesMonitor#warn(java.lang.String, java.lang.Throwable)
118 */
119 public void warn(final String message, final Throwable throwable) {
120 logger.warn(message, throwable);
121 }
122
123 /***
124 * {@inheritDoc}
125 * @see de.bea.domingo.DNotesMonitor#warn(java.lang.String)
126 */
127 public void warn(final String message) {
128 logger.warn(message);
129 }
130
131 /***
132 * {@inheritDoc}
133 * @see de.bea.domingo.DNotesMonitor#error(java.lang.String, java.lang.Throwable)
134 */
135 public void error(final String message, final Throwable throwable) {
136 logger.error(message, throwable);
137 }
138
139 /***
140 * {@inheritDoc}
141 * @see de.bea.domingo.DNotesMonitor#error(java.lang.String)
142 */
143 public void error(final String message) {
144 logger.error(message);
145 }
146
147 /***
148 * {@inheritDoc}
149 * @see de.bea.domingo.DNotesMonitor#fatalError(java.lang.String, java.lang.Throwable)
150 */
151 public void fatalError(final String message, final Throwable throwable) {
152 logger.fatal(message, throwable);
153 }
154
155 /***
156 * {@inheritDoc}
157 * @see de.bea.domingo.DNotesMonitor#fatalError(java.lang.String)
158 */
159 public void fatalError(final String message) {
160 logger.fatal(message);
161 }
162
163 /***
164 * {@inheritDoc}
165 * @see de.bea.domingo.DNotesMonitor#isDebugEnabled()
166 */
167 public boolean isDebugEnabled() {
168 return logger.isDebugEnabled();
169 }
170
171 /***
172 * {@inheritDoc}
173 * @see de.bea.domingo.DNotesMonitor#isInfoEnabled()
174 */
175 public boolean isInfoEnabled() {
176 return logger.isInfoEnabled();
177 }
178
179 /***
180 * {@inheritDoc}
181 * @see de.bea.domingo.DNotesMonitor#isWarnEnabled()
182 */
183 public boolean isWarnEnabled() {
184 return logger.isWarnEnabled();
185 }
186
187 /***
188 * {@inheritDoc}
189 * @see de.bea.domingo.DNotesMonitor#isErrorEnabled()
190 */
191 public boolean isErrorEnabled() {
192 return logger.isErrorEnabled();
193 }
194
195 /***
196 * {@inheritDoc}
197 * @see de.bea.domingo.DNotesMonitor#isFatalErrorEnabled()
198 */
199 public boolean isFatalErrorEnabled() {
200 return logger.isFatalEnabled();
201 }
202 }